package com.cskaoyan.controller;

/**
 * @author pengyehua
 * @date 2020/12/6 20:11
 */

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Issue;
import com.cskaoyan.bean.IssueBO;
import com.cskaoyan.bean.ListData;
import com.cskaoyan.service.AdminIssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商场管理模块的通用问题部分
 */
@RestController
@RequestMapping("admin/issue")
public class AdminIssueController {

    @Autowired
    AdminIssueService adminIssueService;

    /**
     * 模糊查询所有问题
     * @param issueBO
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list(IssueBO issueBO){
        ListData<Issue> issueListData = adminIssueService.queryIssue(issueBO);
        return BaseRespVo.ok(issueListData);
    }

    /**
     * 添加问题
     * @param issue
     * @return
     */
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody Issue issue){
        Issue issueVo = adminIssueService.insertIssue(issue);
        return BaseRespVo.ok(issueVo);
    }

    /**
     * 修改问题
     * @param issue
     * @return
     */
    @PostMapping("update")
    public BaseRespVo update(@RequestBody Issue issue){
        Issue issueVo = adminIssueService.updateIssue(issue);
        return BaseRespVo.ok(issueVo);
    }

    /**
     * 删除问题
     * @param issue
     * @return
     */
    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody Issue issue){
        adminIssueService.deleteIssue(issue);
        return BaseRespVo.ok();
    }
}
